<extend name="Public/user"/>
<block name="link">
	<title>我要下单</title>
	<link href="/static/lida/css/tran_style.css" rel="stylesheet" type="text/css" />
	<link href="__CSS__/bootstrap.min.css" rel="stylesheet"/>
	<script src="__JS__/jquery.js"></script>
	<script src="__JS__/bootstrap.js"></script>
	<link href="__CSS__/ksfh-style.css" rel="stylesheet"/>
	<link rel="stylesheet" type="text/css" href="__CSS__/common.css">
	<link href="__CSS__/blue.css" rel="stylesheet">
	<script type="text/javascript" src="__STATIC__/thinkbox/thinkbox/jquery.thinkbox.js"></script>
</block>

<block name="user-right">
	<style type="text/css">
		.address-form{
			position: absolute;
			width: 270px;
			padding: 20px;
			border: 1px solid red;
			top: -1px;
			left: -1px;
			background: #fff;
			min-height: 160px;
			display: none;
			z-index: 1000;
		}
		.form-control{
			max-width: 94%;
		}
		form{
			margin: 0;
			padding: 0;
			border: none;
			list-style-type: none;

		}
		.user-right .user-address .address-form input[type="text"]{
			width: 96%;
			padding: 2%;
			border: 1px solid #dfdfdf;
		}
		.down_menu li a{
			margin: 0 8px 6px;
		}
		.num{margin-left: 3px ;margin-right: 3px;color: #AB263C;}
		.current{color: #AB263C;}
		.blank{height: 10px;clear: both;}
		.btnqx{background: #fafafa;border: 1px solid #dfdfdf;width: 48%;padding: 5px 0;float: left;cursor: pointer;text-align: center;}
		.btnqd{background: #fafafa;border: 1px solid red;width: 48%;padding: 5px 0;float: right;background: red;color:#fff;cursor: pointer;text-align: center;}
	</style>
	<script>
		$(document).ready(function(){
			$('input').iCheck({
				checkboxClass: 'icheckbox_minimal-blue',
				radioClass: 'iradio_minimal-blue',
				increaseArea: '20%' // optional
			});
		});
	</script>
	<!--main_right-->
	<div class="main_r f_fr">
		<div class="user_kx">
			<h3 class="user_kx_title">
				我要转移
				<button type="button"  style="float:right;margin-top:20px;" target-form="ids" url="{:url('Switch/addPrimarySwitchList')}"   class=" ajax-post btn btn-default">添加到仓转单</button>
			</h3>
			<table class="table table-striped table-bordered">

				<tbody>
				<tr>
					<th class="w20"><input id="check-all"   type="checkbox"></th>
					<th class="w90">快递单号</th>
					<th class="w100">包裹名称</th>
					<th class="w80">价值(日元)</th>
					<!--
                                        <th class="w70">{:lang('baoguo_leixing')}</th>
                    -->
					<th class="w160">备注</th>
					<th class="w80">重量(kg)</th>
					<th class="w100">状态</th>
					<th class="w100">添加时间	</th>
					<th class="w80">操作	</th>

				</tr>
				<if condition="$list">
					<volist name="list" id="v">

						<tr class=""  id='yubao_info_{$v.id}'  <eq name="v.baoguo_type" value="1">style="background:#FFFFE7;color:red;"</eq>>
						<th  width="20px"><input class="ids" type="checkbox" value="{$v['id']}" name="ids[]"></th>
						<td>{$v.kuaidi_sn}</td>
						<td>{$v['baoguo_name']? $v['baoguo_name']:''}</td>
						<td>{$v['jiazhi']? $v['jiazhi']:''}</td>
						<td>{$v['remark']? $v['remark']:''}</td>
						<td>{$v.weight}</td>
						<td>{$v.status|getyubaostatus}</td>
						<td>{$v.add_time|time_format='Y-m-d'}</td>
						<td><a href="###"  class="add_cz "  url='{:url("Switch/addPrimarySwitchList",array("ids"=>$v["id"]))}' >添加</a></td>
						</tr>
					</volist>
					<else />
					<tr >
						<td style="padding:5px;text-align: center; line-height:16px;" colspan="11">暂时没有信息</td>
					</tr>
				</if>
				</tbody>


			</table>
			<div style="word-spacing:5px; letter-spacing: 1px;">{$_page} </div>
		</div>
		<style type="text/css">
			.addedcell{position: relative;}
			.addedcell .delcell{position: absolute;top: 1px;right: 0;display: block;background: red;color: #fff;padding: 2px 10px;height: 16px;line-height: 16px;}
			.listcell{position: relative;}
			.listcell .dellistcell{position: absolute;top: 1px;right: 0;display: block;background: red;color: #fff;padding: 2px 10px;height: 16px;line-height: 16px;}
			#addresslist{display: none;position: relative;}
			.yubao-add .address-form{position: absolute;width: 285px;padding: 20px;border: 1px solid red;bottom: -35px;left: -1px;background: #fff;min-height: 160px;display: none;}
			.yubao-add .address-form input[type="text"]{width: 96%;padding: 2%;border: 1px solid #dfdfdf;}
			.yubao-add .address-form select{border: 1px solid #dfdfdf;}

		</style>
		<div class="user_kx">
			<h3 class="user_kx_title">
				转移单列表
			</h3>
			<form class="form-inline" method="post" action="{:url('Switch/addToDoSwitchList')}" id="ybcartadd">
				<table class="yubao-add table table-striped table-bordered" id="yubaoinput" style="border:none;">
					<tbody>
					<tr>
						<th class="w90">快递单号</th>
						<th class="w100">包裹名称</th>
						<th class="w80">价值(日元)</th>
						<!--
                                            <th class="w70">{:lang('baoguo_leixing')}</th>
                        -->
						<th class="w160">备注</th>
						<th class="w80">重量(kg)</th>
						<th class="w100">状态</th>
						<th class="w100">添加时间	</th>
						<th class="w80">操作	</th>

					</tr>
					<if condition="$czSelect">
						<volist name="czSelect" id="v">

							<tr >
							<td>{$v.kuaidi_sn}</td>
							<td>{$v['baoguo_name']? $v['baoguo_name']:''}</td>
							<td>{$v['jiazhi']? $v['jiazhi']:''}</td>
							<td>{$v['remark']? $v['remark']:''}</td>
							<td>{$v.weight}</td>
							<td>{$v.status|getyubaostatus}</td>
							<td>{$v.add_time|time_format='Y-m-d'}</td>
							<td><a href="###"  class=" cancel_cz"   did="{$v.id}"   url='{:url("Switch/recallCz",array("id"=>$v["id"]))}'>取消仓转</a></td>
							<input type="hidden" class="sel-id" name="sid[]" value="{$v.id}"/>
							</tr>
						</volist>
						<else />
						<tr >
							<td style="padding:5px;text-align: center; line-height:16px;" colspan="11">暂时没有信息</td>
						</tr>
					</if>
					</tbody>

				</table>
				<table class="table table-bordered">
					<tbody>

					<tr>
						<td>
							<div class="form-group">
								<label for="exampleInputName2">
									<span style="color:#F00;"><strong>填写仓转对象：</strong></span>
								</label>
								<input style="display:none" />   
								<input type="text"   class="to_id"  placeholder="如LD000123" style='width: 100px;linx-height:20px;height:20px;border:1px solid black;'  name='to_user' value=''><span></span>
								&nbsp;&nbsp;&nbsp;<button type="button" class="ybcartinbtn btn btn-danger" style="background:#F00;font-size: inherit;height: 11px;padding: 2px 5px 9px 5px;">提交仓转</button>
							</div>
						</td>
					</tr>
					<tr>
						<td>
							<div class="form-group">
								<label for="exampleInputName2">
									<span style="color:#F00;"><strong>填写转仓对象：</strong></span>
								</label>
								<input style="display:none" />   
								<input type="text"   class="to_other_id"  placeholder="格式联系客服" style='width: 100px;linx-height:20px;height:20px;border:1px solid black;'  name='to_other_user' value=''><span></span>
								&nbsp;&nbsp;&nbsp;<button type="button" class="btn btn-danger yb-zc" style="background:#F00;font-size: inherit;height: 11px;padding: 2px 5px 9px 5px;">提交转仓</button>
							</div>
						</td>
					</tr>
					</tbody>
				</table>
				<div class="user_btn">
					
				</div>
			</form>

		</div>
	</div>
</block>

<block name="javascript">
	<script type="text/javascript">

		//ajax post submit请求
		$('.ajax-post').click(function(){
			var target,query;
			var target = $(this).attr('url');
			var target_form = $(this).attr('target-form');
			var that = this;
			query =  $('.'+target_form).serialize();
			$.post(target,query).success(function(data){
				location.reload();
			});

		});


		//全选的实现
		$("#check-all").click(function(){
			$(".ids").prop("checked", this.checked);
		});

		$(".ids").click(function(){
			var option = $(".ids");
			option.each(function(i){
				if(!this.checked){
					$(".check-all").prop("checked", false);
					return false;
				}else{
					$(".check-all").prop("checked", true);
				}
			});
		});


		//ajax post submit请求
		$('.cancel_cz').click(function(){
			var target,query;
			var target = $(this).attr('url');
			var that = this;
			$.get(target).success(function(data){
                if (data.result == 0){
					location.reload();

				}
			});


		});

		$('.to_id').bind('input propertychange', function() {

			var  transforId = $(this).val();
			var  that = this;
			$.ajax({
				type: "POST",
				url:'{:url("User/checkId")}',
				data:{"id":transforId},
				success: function(data) {
					$(that).next().remove();
					if (data.result == 0 ) {
						$(that).after('<span style="color:green;margin-left:10px;" class="yes">仓转对象存在,可以仓转</span>');
					} else if( data.result == 1){
						$(that).after('<span style="color:red;margin-left:10px;" class="no">不能仓转给自己</span>');
					}else{
						$(that).after('<span style="color:red;margin-left:10px;" class="no">仓转对象不存在,请重新输入</span>');

					}

				}
			});


		});
		//ajax post submit请求
		$('.add_cz').click(function(){
			var target;
			var target = $(this).attr('url');
			var that = this;
			$.get(target).success(function(data){
				location.reload();
			});


		});

		// 转仓
		$('.yb-zc').click(function(){
			if($('.sel-id').val() == undefined ){
				$.thinkbox.error('转移单为空不能转仓!');
				return;
			}
			if(!$('.to_other_id').val()){
				$.thinkbox.error('请输入仓转对象！');
				return;
			}
			$.ajax({
				type: "POST",
				url:'{:url("")}',
				data:{to_other_id:$('.to_other_id').val()},
				success: function(result) {
					if(0 == result.status){
						$.thinkbox.success(result.message);
						setTimeout('location.reload()',1000);
					}else{
						$.thinkbox.error(result.message);
					}
				}
			});
		})
		$('.ybcartinbtn').click(function(){
			if($('.sel-id').val() == undefined ){
				$.thinkbox.error('转移单为空不能转仓!');
				return;
			}
			if( ($('.to_id').next().attr('class') == 'no')   ){

			}else if(($('.to_id').next().attr('class') == undefined)){
				$('.to_id').next().remove();
				$('.to_id').after('<span style="color:red;margin-left:10px;" class="no">仓转对象不存在,请重新输入</span>');
			}else {
				$.ajax({
					type: "POST",
					url:'{:url("")}',
					data:{to_user:$('.to_id').val()},
					success: function(result) {
						if(0 == result.status){
							$.thinkbox.success(result.message);
							setTimeout('location.reload()',1000);
						}else{
							$.thinkbox.error(result.message);
						}
					}
				});
				//$('#ybcartadd').submit();
			}
		})
	</script>
</block>